package oop.ex3.nameserver.actions;

import java.io.IOException;
import java.net.InetSocketAddress;

import oop.ex3.messages.FileMessage;
import oop.ex3.messages.MessageInterface;
import oop.ex3.messages.SimpleMessage;
import oop.ex3.messages.ValidHeaders;

import oop.ex3.nameserver.NSContext;
import oop.ex3.sockets.ClientSocket;

public class DeleteFile extends NsAction {

	public DeleteFile(NSContext context){
		super(context);
	}

	@Override
	public boolean run(ClientSocket socket, MessageInterface msg) {
		//TODO how do you know which FM requested?
		_context.deleteFromFileList(((FileMessage)msg).getFileName(), 
				socket.getOtherPeer());
		_context.deleteFromFm(((FileMessage)msg).getFileName(), 
				socket.getOtherPeer());
		return sendDone(socket);
	}

}
